﻿using System;
using System.Collections.Generic;
using FinPlusComponents;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FinPlusAnalytics
{
    public class VolSurf : FinPlusComponent
    {
        public string Name { get; private set; }

        //construct
        public VolSurf(string marketName, string name, string volSurfName, string vols, string index, string model)
        {
            Name = name;

            //TODO
            //Boost::shared_ptr<IborIndex> indx = indexs[marketName][index];
            //if(!indx) return "#unknown index";
		
            //boost::shared_ptr<QuantLib::YieldTermStructure> curve = rateCurves[marketName][curveName];
            //if(!curve) return "#unknown curve";
		
            //std::vector<std::vector<std::string>> v1 = stringTo2DVector(vols);
            //std::vector<boost::shared_ptr<CalibrationHelper>> calibHelpers;

            //int i = 0;
            //std::string periodLabel;
            //QuantLib::Period maturity;
            //for each(std::vector<std::string> v2 in v1)
            //{
            //    if(i > 0)
            //    {
            //        int j = 0;
            //        maturity = getPeriod(v1[0][i]);
            //        vsurfPeriodLabels[marketName][volSurfName].push_back(maturity);

            //        QuantLib::Period period;
            //        for each(std::string v in v2)
            //        {
            //            if(j > 0 && stod(v) > 0)
            //            {
            //                period = getPeriod(v1[j][0]);
            //                if(i == 1)	
            //                    vsurfMaturityLabels[marketName][volSurfName].push_back(period); 
            //                calibHelpers.push_back(boost::shared_ptr<CalibrationHelper>(new SwaptionHelper(maturity, period, setQuote(marketName, "", stod(v)), indx, indx->tenor(), indx->dayCounter(), indx->dayCounter(), Handle<QuantLib::YieldTermStructure>(curve))));
            //                vsurfMarketVols[marketName][volSurfName].push_back(stod(v));
            //            }
            //            j++;
            //        }
            //    }
            //i++;
            //}

            //vsurfCalibHelpers[marketName][volSurfName] = calibHelpers;
            //std::vector<std::string> modelVector = stringToVector(model);
		
            //std::string engineName;
		
            ////sabre??????????
            //if(modelVector[0] == "G2") engineName = SwaptionG2Engines(marketName, curveName, volSurfName, stod(modelVector[1]), stoi(modelVector[2]));
            //else if(modelVector[0] == "HW1") engineName = SwaptionHW1Engines(marketName, curveName, volSurfName);
            //else if(modelVector[0] == "HW2") engineName = SwaptionHW2Engines(marketName, curveName, volSurfName, stoi(modelVector[1]));
            //else if(modelVector[0] == "BK") engineName = SwaptionBKEngines(marketName, curveName, volSurfName, stoi(modelVector[1]));

        }
    }
}
